package Controller;

import Pojo.Menu;
import Service.impl.MenuServiceImpl;
import com.alibaba.fastjson.JSON;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

public class MenuQueryAllServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        MenuServiceImpl menuService=new MenuServiceImpl();
        List<Menu> menuList=menuService.MenuQueryAll();
        System.out.println(menuList);
        response.getWriter().print(JSON.toJSONString(menuList));
    }
}
